# Program ID Number:Program1.s
# Written by    :Beatris Rusu
# Date Created  :8/27/06
# Revision:	1.0
# Demonstrate first assmbly program
# Use the addition instruction to complete each operation
# and put the result in its own memory location:
#  69 + 12 = ? given as example
#  69 + (-12) = ?
#  (-69) + 12 = ?
#  (-69) + (-12) =? 
# Revisions made, date of revision, author:
#          First release   8/27/06	David Smith
#
.text
.globl main
# Display the two numbers.
main:	
addi	$sp, $sp, -4	# Make space on stack.
sw	$ra, 0($sp)	# Save return address.	
li 	$t0, 0xcafe	# I want to load 0xcafe
li	$t1, 0xBEAD	# I want to load 0xcafe
	li 	$t2, 0xDEAF
	li	$t3, 0xDEED	
	la 	$a0, WORD1	# Get the address o
	move   	$s0, $a0	# save address
	sw	$t0, 0($s0)	# store data in word 1	
	## Here I continued to use offsets to be shorter, but I should repeat what I did above for each word
	sw	$t1, 4($s0)	# store data in word 2
	sw 	$t2, 8($s0)	# store data in word 3
	sw	$t3, 12($s0)	
	move	$t0, $zero	#li 	$t0, 0  --clear those registers
	move	$t1, $zero	#li	$t1, 1
	move	$t2, $zero
	move	$t3, $zero	
	la	$a0, BEGIN 	#Or I can just do it in one instruction -- lw	$t0, BEGIN
	move	$s0, $a0	#
	lw	$t0, 0($s0)	#	
	#Same hear again, I should have done it how I did it for $t0 for all of them, 
	#and not using offsets. It works, but it is not quite conventional.
	lw	$t1, 4($s0)
	lw	$t2, 8($s0)
	lw	$t3, 12($s0)	
	li	$v0, 0		# Return zero.
	lw	$ra, 0($sp)	# Restore return address.
	addi	$sp, $sp, 4	# Restore stack pointer.
	jr	$ra
.data	
BEGIN: .word 0xADDE 
WORD1: .word  0
WORD2: .word  0
WORD3: .word  0
WORD4: .word  0
WORD5: .word  0 
MYNAME: .asciiz "Beatris"
# $Id: Exercise1.s,v 1.0 2006/08/27 16:22:10 parks Exp $
# Authors: David L. Smith
